package com.sc.pattern.balking;

import java.io.IOException;

/**
 * Created  on 2018/1/7.
 *
 * @author sc
 */
public class Customer extends Thread{

    private final BalkingData balkingData;

    public Customer(BalkingData balkingData){
        super("customer");
        this.balkingData = balkingData;
    }

    @Override
    public void run() {
        try {
            balkingData.save();
            for (int i = 0; i < 20; i++) {
                balkingData.change("hello "+i);
                Thread.sleep(1000);
                balkingData.save();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
